package com.xlh.service.courseTest;

import com.github.pagehelper.PageInfo;
import com.xlh.dto.course.ChapterBasicInfoDTO;
import com.xlh.dto.courseTest.DuplicateResultDTO;
import com.xlh.dto.courseTest.ReportDTO;
import com.xlh.dto.courseTest.UserPaperExperimentReportDTO;
import com.xlh.dto.courseTest.check.*;
import com.xlh.dto.courseTest.experiment.ExperimentChapterStatisticsDTO;
import com.xlh.enums.courseTest.ReportTypeEnum;
import com.xlh.param.check.CheckSubmitParam;
import com.xlh.param.courseTest.ExperimentStatisticsAllParam;
import com.xlh.param.courseTest.ExperimentStatisticsParam;
import com.xlh.param.courseTest.ReportParam;
import com.xlh.pojo.courseTest.CourseTestPaper;
import com.xlh.pojo.courseTest.CourseTestPaperAnswerSheet;
import com.xlh.pojo.courseTest.ExperimentReport;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author zhr 2019/4/3
 */
public interface ExperimentService {
    /**
     * 获取实验报告及实验报告下载地址
     */
    ReportDTO getReport(Long courseId, Long chapterId, Long userId);

    /**
     * 根据章节id列表删除实验报告
     */
    void deleteByChapterIds(List<Long> chapterIds);

    /**
     * 根据学生id和章节id删除实验报告
     */
    void deleteByStudentIdsChapterIds(List<Long> userIds, List<Long> chapterIds);

    ExperimentReport selectByPrimaryKey(Long id);

    void updateByPrimaryKey(ExperimentReport experimentReport);

    List<StudentListDTO> listStudent(Long classId, Long chapterId, Integer status, String studentInfo, Long userId);

    List<ExperimentReport> selectByChapterIds(List<Long> chapterIds);

    List<ExperimentReport> selectSubmitByChapterIdStudentIds(Long chapterId, List<Long> students);

    void setPoint(ExperimentReportDTO result, Long id, List<ExperimentReport> reportList);

    void setDetails(ExperimentReportDTO result, ExperimentReport report, List<ExperimentReport> reportList, Long courseId);

    /**
     * 上传实验报告
     */
    String uploadReport(Long chapterId, Long courseId, MultipartFile file, Long userId, String username);

    /**
     * 保存在线实验报告
     */
    void saveReport(Long chapterId, Long courseId, ReportParam param, Long userId);

    /**
     *
     * 保存视频或者实验时长
     */
    void saveExperimentTime(Long chapterId, Long courseId, Long classId, Long userId, Integer pass);

    Integer queryExperiment(Long chapterId, Long courseId, Long classId, Long userId);

    List<Map<String,Object>> queryeExperimentTime(Long chapterId, Long courseId, Long classId, Long userId);

    PageInfo<Map<String, Object>> experimentStatisticsPass(Long chapterId, Long courseId, Long classId, Long userId, Integer pageSize, Integer currentPage);

    String experimentStatisticsVideoFind(Long chapterId, Long courseId, Long classId, Long userId, Long taskId, Long stepId);

    void DeleteExperimentVideo(Long chapterId, Long courseId, Long taskId, Long stepId);

    void saveExperimentTime(Long chapterId, Long courseId, Long classId, Long userId, String videotime, Long taskId, Long stepId, String type);

    void download(List<ExperimentStatisticsParam> passStudent);

    void downloadAll(ExperimentStatisticsAllParam passStudent, String courseName, String chapterName, String className);
    /**
     * 获得实验报告查重结果
     *
     * @param reportList             待查重的其余实验报告
     * @param studentReport          待查重学生的实验报告
     * @param reportDuplicatePercent 查重警告百分比
     */
    List<DuplicateResultDTO> getDuplicateResult(List<ExperimentReport> reportList, ExperimentReport studentReport, Integer reportDuplicatePercent);

    /**
     * 用户已提交的实验报告次数
     */
    Long getCount(Long userId, ReportTypeEnum reportTypeEnum);

    /**
     * 上传考试的实验报告
     */
    String uploadTestReport(Long answerSheetId, Long questionId, MultipartFile file, String username);

    /**
     * 保存在线实验报告
     */
    void saveTestReport(Long answerSheetId, Long questionId, ReportParam param);

    List<ChapterCountDTO> countGroupByChapterIdClassId(List<Long> chapterIds);

    /**
     * 查询考试实验报告,若无实验报告,则异步插入一条新记录
     */
    ReportDTO selectInsertTest(Long answerSheetId, Long questionId, Long userId, Long courseId);

    void asyncInsertTest(Long answerSheetId, Long questionId, Long userId);

    List<StudentBaseListDTO> listStudentBase(Long courseId, Long userId);

    List<UserPaperExperimentReportDTO> selectByIdsExt(List<Long> reportIds);

    Map<Long, List<DuplicateResultDTO>> mapQuestionDuplicate(
            CourseTestPaperAnswerSheet answerSheet, List<UserPaperExperimentReportDTO> experimentReportList,
            CourseTestPaper paper
    );

    /**
     * 修改考试实验报告的提交状态
     * @param answerSheetId 答题卡id
     */
    void updateTestCommit(Long answerSheetId);

    /**
     * 保存归档pdf文件至服务器
     * @param fileName
     * @param param
     */
    void updatePDF(String fileName, CheckSubmitParam param);

    List<ExperimentReport> selectByChapterIdsClassId(List<Long> chapterIds, Long classId);

    List<ClassUncheckedCountDTO> selectUncheckedByCourseIds(List<Long> courseIdList);

    List<ExperimentReport> selectByAnswerSheetIds(List<Long> answerSheetIds);

    /**
     * 章节实验统计
     * @param taskId
     * @param classId
     * @return
     */
    ExperimentChapterStatisticsDTO experimentChapterStatistics(Long taskId, Long classId);

    /**
     * 查询章节下任务ID
     * @param chapterId
     * @param classId
     * @return
     */
    List<ChapterBasicInfoDTO> getChapterTaskId(Long chapterId, Long classId);


    /**
     * 学生各实验统计情况下载（
     *      理论，理论及多实验，理论及实验，实验
     * ）
     * @param taskId
     * @param classId
     */
    boolean chapterStatisticsDownLoad(Long taskId, Long classId);
}
